package priv.happy.mealpickpro.config;


import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.context.annotation.Configuration;
import org.springframework.web.servlet.config.annotation.InterceptorRegistry;
import org.springframework.web.servlet.config.annotation.WebMvcConfigurer;
import priv.happy.mealpickpro.interceptor.AuthenticationInterceptor;

 @Configuration
public class InterceptorConfig implements WebMvcConfigurer {

    @Autowired
    AuthenticationInterceptor authenticationInterceptor;

    @Override
    public void addInterceptors(InterceptorRegistry registry) {
        // 这里不能直接new， 否则就会报空指针，因为是自己new的
        registry.addInterceptor(authenticationInterceptor)
                .addPathPatterns("/api/**")  // 所有请求都被拦截
                .excludePathPatterns("/api/v2/login/**", "/api/v2/register/**", "/api/v2/resetpassword/**"); //放行的请求
    }
}
